<?php

// @formatter:off
/**
 * @file config.php
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: config.php 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/config/config.php $
 */
// @formatter:on

$wcROOTDIR = dirname(__DIR__);
$wcROOTURI = substr($wcROOTDIR, strlen($_SERVER["DOCUMENT_ROOT"]));
//
// Detecting command line access.
if(php_sapi_name() == "cli") {
	define("__SHELL__", php_sapi_name());
}
//
// Detected mobile access.
if(!defined("__SHELL__") && isset($_SERVER["HTTP_USER_AGENT"]) && preg_match('/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine|htc|iemobile|iphone|ipad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|panasonic|philips|phone|sagem|sharp|sie-|smartphone|sony|symbian|t-mobile|telus|up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i', $_SERVER["HTTP_USER_AGENT"])) {
	define("__IS_MOBILE__", true);
}

require_once "{$wcROOTDIR}/config/defines.php";

// @formatter:off
/**
 * @todo documentar
 * @var int
 */
$wcErrno = 0;
/**
 * @todo documentar
 * @var string
 */
$wcError = "";
/**
 * List of componet versions.
 * @var array
 */
$wcVersions = array();
/**
 * List of default parameters.
 * @var array
 */
$wcDefaults = array();
/**
 * Site specific configurations.
 * @var array
 */
$wcSite = array();
/**
 * List of handlers for service.php.
 * @var array
 */
$wcServicesHandlers = array();
/**
 * List of services.
 * @var array
 */
$wcServices = array();
/**
 * List of handlers for rss.php.
 * @var array
 */
$wcRSSHandlers = array();
/**
 * List of useful locations.
 * @var array
 */
$wcPaths = array();
/**
 * Permissions assignments
 * @todo explicar.
 * @var array
 */
$wcPermissions = array(
	"_names" => array(
		"profiles" => array("*", "ROOT", "ADMIN", "ORGANIZER", "COLLECTOR", "TAGGER", "USER", "ANON"),
		"methods" => array("*", "POST", "GET"),
		"pages" => array("*", "index", "mobile", "simple", "service", "rss")
	),
	"default" => "ANON",
	"pyramid" => array(),
	"rights" => array(),
	// Each permission assigned through pyramid-perms will also be assigned to
	// higher ranking users.
	"pyramid-perms" => array(),
	// Each permission assigned through direct-perms will only be assigned to
	// the specified user rank.
	"direct-perms" => array()
);
/**
 * @TODO documentar
 * @var mixed[string]
 *
 * @code
 * array(
 * 	'name' => array(
 * 		"description"	=> "brief description",			// mandatory
 * 		"class"		=> "class-name",			// mandatory
 * 		"path"		=> "file where the class is stored",	// optional
 * 		...
 * 	),
 * 	...
 * )
 * @endcode
 */
$wcActiveTagHooks = array();
/**
 * @TODO documentar
 * @var string[]
 */
$wcSpecialTags = array();
/**
 * @var array
 * @code
 * 	$wcExtensionInfo[] = array(
 * 		'name'		=> "NAME",
 * 		'description'	=> "DESCRIPTION",
 * 		'version'	=> "VERSION_STRING",
 * 		'url'		=> "HOMEPAGE_LINK",
 * 		'author'	=> "AUTHOR"
 * 	);
 * @endcode
 *
 * Also:
 * @code
 * 	$wcExtensionInfo[] = array(
 * 		'name'		=> "NAME",
 * 		'description'	=> "DESCRIPTION",
 * 		'version'	=> "VERSION_STRING",
 * 		'url'		=> array(
 * 					"title"	=> "LINK_TITLE",
 * 					"href"	=> "HOMEPAGE_LINK"
 * 				   ),
 * 		'author'	=> "AUTHOR"
 * 	);
 * @endcode
 */
$wcExtensionInfo = array();
/**
 * @var array
 * List of hooks for rules actions manager.
 * Every item must be added in this way:
 * @code
 * 	$wcRuleHooks[ALFANUMERIC_CODE_TO_IDENTIFY_ITS_TYPE] = array(
 * 		'name'		=> "ACTION_TYPE_NAME",
 * 		'description'	=> "ACTION_TYPE_DESCRIPTION",
 * 		'class'		=> "ACTION_TYPE_MAIN_CLASS_NAME",
 * 		'page'		=> "FULL_PATH_TO_EDITION_PAGE.php",
 * 		'conficts'	=> "FUNCTION_NAME",			[OPTIONAL]
 * 		'version'	=> "EXTENSION_VERSION_STRING",
 * 		'url'		=> "EXTENSION_HOMEPAGE_LINK",
 * 		'database'	=> "DATABASE_CHECK_FUNCTION"		[OPTIONAL]
 * 	);
 * @endcode
 */
$wcRuleHooks = array();
/**
 * @var string[string][]
 * Each element must be added like this:
 * @code
 * 	$wcCanvasActions["subaction-name"] = array(
 * 		"manager"	=> "php-manager-path",
 * 		"template"	=> "template-full-path"
 * 	);
 * @endcode
 */
$wcCanvasActions = array();
/**
 * @var string[string][]
 * Each element must be added like this:
 * @code
 * 	$wcRightTools[] = array(
 * 		"title"		=> "Section Title",
 * 		"manager"	=> "php-manager-path",
 * 		"template"	=> "template-full-path",
 * 		"checker"	=> "optional-functioname",
 * 		"times"		=> "repeat"
 * 	);
 * @endcode
 */
$wcRightTools = array();/** @deprecated */
/**
 * @var string[string][]
 * Each element must be added like this:
 * @code
 * 	$wcSideTools[] = array(
 * 		"action"	=> "template-full-path",
 * 	);
 * @endcode
 */
$wcSideTools = array();
$wcSideTools[] = array(
	"action" => "sidetools:search"
);
/**
 * @var string[string][]
 * Each element must be added like this:
 * @code
 * 	$wcRightAdds[] = array(
 * 		"manager"	=> "php-manager-path",
 * 		"template"	=> "template-full-path",
 * 		"checker"	=> "optional-functioname",
 * 		"times"		=> "repeat"
 * 	);
 * @endcode
 */
$wcRightAdds = array();
/**
 * Database access information. It must contain these associative elements:
 * 	- server	Server where the database is hosted.
 * 	- username	Username with permission to use the database.
 * 	- password	Password for the given username.
 * 	- database	Database name.
 *
 * It may also contain:
 * 	- prefix	Prefix for every table. By default it is "wc_".
 * @var array
 */
$wcDatabaseAccess = array(
	"server" => false,
	"username" => false,
	"password" => false,
	"database" => false,
	"prefix" => "wc_"
);
$wcDatabase = array(
	"aggressive" => false,
	"indexes" => array(),
	"tables" => array()
);

/**
 * Configuration for cron.php.
 * Every item must be added in this way:
 * 	$wcCronScripts[NUMERIC_ID] = array(
 * 		"name"		=> "TITLE",
 * 		"path"		=> "FULL_PATH.php",
 * 		"params"	=> array(
 * 			"PARAM1",
 * 			"PARAM2"
 * 		),
 * 		"url"		=> "EXTENSION_HOMEPAGE_LINK"
 * @todo UPDATE
 * 	);
 *
 * @var array
 */
$wcCronScripts = array();
/**
 * @todo doc
 * @var string
 */
$wcCronProfile = "default";
/**
 * @todo doc
 * @var array
 */
$wcCronProfiles = array();
/**
 * Configuration for tool.php.
 * Every item must be added in this way:
 * 	$wcToolScripts[ALFANUMERIC_ID] = array(
 * 		"name"		=> "TITLE",
 * 		"path"		=> "FULL_PATH.php", [OPTIONA]
 * 		"url"		=> "EXTENSION_HOMEPAGE_LINK"
 * 	);
 *
 * @var array
 */
$wcToolScripts = array();
/**
 * @TODO documentar
 * @var WCTheme
 * @deprecated
 */
$wcTheme = false;
/**
 * @TODO documentar
 * @var array()
 * @deprecated
 */
$wcThemeClasses = array();
/**
 * @TODO documentar
 * @var array()
 * @deprecated
 */
$wcThemeDefaults = array();
/**
 * @TODO documentar
 * @var array()
 * @deprecated
 */
$wctDefaults = array();
/**
 * Skin Default Settings.
 * @TODO documentar
 * @var array()
 */
$wcsDefaults = array();
/**
 * @var multitype
 */
$wcUserXData = array(
	"_types" => array(
		"date", "string", "text", "number", "list"
	),
	"_fields" => array(
		"name", "title", "type", "values", "default"
	),
	"_names" => array(),
	array(
		"name" => "BIRTHDAY",
		"title" => "Birth Day",
		"type" => "date",
		"values" => false,
		"default" => ""
	),
	array(
		"name" => "GENDER",
		"title" => "Gender",
		"type" => "list",
		"values" => array("male", "female", "untold"),
		"default" => "untold"
	)
);
//
// Skin Variables: @{
$wcSkin = false;
$wcSkinDefaults = array();
$wcSkinDefaults["action"] = WC_ACTION_RANDOM;
$wcSkinDefaults["mobile-action"] = WC_ACTION_MENU;
$wcSkinDefaults["layout"] = "index";
$wcSkinDefaults["mobile-layout"] = "index";
$wcSkinDefaults["cache"] = array();
$wcSkinDefaults["cache"]["active"] = false;
$wcSkinDefaults["cache"]["invalids"] = true;
$wcSkinDefaults["cache"]["expiration"] = 3600; // 1 hour.
$wcSkinDefaults["header"] = array();
$wcSkinDefaults["header"]["styles"] = array();
$wcSkinDefaults["header"]["scripts"] = array();
$wcSkinConfig = new stdClass();
// @}
define("WC_USER_ROOT_ID", "1");
define("WC_USER_CRON_ID", "2");
define("WC_USER_ROOT_NAME", "root");
define("WC_USER_CRON_NAME", "cron");

$wcPatterns = array();
$wcPatterns["comic-patterns"] = array('/\.cbz$/', '/\.cbr$/', '/\.cbt$/', '/\.zip$/', '/\.rar$/', '/\.tar$/');
$wcPatterns["image-patterns"] = array('/\.jpg$/', '/\.gif$/', '/\.png$/', '/\.jpeg$/', '/\.GIF$/', '/\.JPG$/', '/\.PNG$/', '/\.JPEG$/');
$wcPatterns["image-paths"] = array('/\.jpg$/', '/\.png$/', '/\.jpeg$/', '/\.JPG$/', '/\.PNG$/', '/\.JPEG$/');
$wcPatterns["info-paths"] = array('/gallery\.xml$/', '/url\.xml$/');
$wcReplaceURL = array(
	'in' => array('%', '+', '#', 'ñ', 'Ñ', ' ', '&'),
	'out' => array('%25', '%2B', '%23', '%A4', '%A5', '%20', '%26')
);
$wcReplacePath = array(
	'in' => array('.', '[', ']', '(', ')', '%', '^', '+'),
	'out' => array('\\.', '\\[', '\\]', '\\(', '\\)', '\\%', '\\^', '\\+')
);

/**
 * Global Preconfiguration
 * @{
 */
$wcDatabaseAccess["server"] = false;
$wcDatabaseAccess["username"] = false;
$wcDatabaseAccess["password"] = false;
$wcDatabaseAccess["database"] = false;

$wcVersions["name"] = "wcomix";
$wcVersions["version"] = "2.0";
$wcVersions["jquery"] = "1.10.2";
$wcVersions["jqueryui"] = "1.10.3";

$wcPaths["config-local"] = "{$wcROOTDIR}/local.conf.php";
$wcPaths["cache-directory"] = "{$wcROOTDIR}/cache";
$wcPaths["config-directory"] = "{$wcROOTDIR}/config";
$wcPaths["includes-directory"] = "{$wcROOTDIR}/includes";
$wcPaths["includes-directory-uri"] = "includes";
$wcPaths["services"] = "services";
$wcPaths["services-directory"] = "{$wcROOTDIR}/{$wcPaths["services"]}";
$wcPaths["rss-directory"] = "{$wcROOTDIR}/rss";
$wcPaths["tools-directory"] = "{$wcROOTDIR}/tools";
$wcPaths["cron-directory"] = "{$wcROOTDIR}/cron";
$wcPaths["cache-directory-uri"] = 'cache';
$wcPaths["cache-js-uri"] = 'js';
$wcPaths["cache-thumbs-dirname"] = 'thumbs';
$wcPaths["cache-expand-dirname"] = 'expanded';
$wcPaths["install-directory"] = "{$wcROOTDIR}/install";
$wcPaths["extensions-directory"] = "{$wcROOTDIR}/extensions";
$wcPaths["extensions-directory-uri"] = "extensions";
$wcPaths["logs-directory"] = "{$wcPaths["cache-directory"]}/logs";
$wcPaths["captcha-directory"] = "{$wcPaths["includes-directory"]}/securimage";
$wcPaths["captcha-directory-uri"] = "{$wcPaths["includes-directory-uri"]}/securimage";
/*
 * Installation temporary paths.
 * @{
 */
$wcPaths["install-tmps"] = array();
$wcPaths["install-tmps"]["defaults"] = "{$wcPaths["cache-directory"]}/install.defaults.php";
$wcPaths["install-tmps"]["step"] = "{$wcPaths["cache-directory"]}/install.step.php";
$wcPaths["install-tmps"]["db"] = "{$wcPaths["cache-directory"]}/install.db.php";
$wcPaths["install-tmps"]["group"] = "{$wcPaths["cache-directory"]}/install.group.php";
$wcPaths["install-tmps"]["cron"] = "{$wcPaths["cache-directory"]}/install.cron.php";
$wcPaths["install-tmps"]["cron-check"] = "{$wcPaths["cache-directory"]}/install.cron-check.php";
/* @} */
/*
 * MVC paths.
 * @{
 */
$wcPaths["mvc"] = array();
$wcPaths["mvc"]["include"] = "{$wcPaths["includes-directory"]}/mvc";
$wcPaths["mvc"]["include-uri"] = "{$wcPaths["includes-directory-uri"]}/mvc";
$wcPaths["mvc"]["config"] = "{$wcROOTDIR}/frontview/config.php";
$wcPaths["mvc"]["tools"] = "{$wcROOTDIR}/frontview/includes";
$wcPaths["mvc"]["actions"] = "{$wcROOTDIR}/frontview/actions";
$wcPaths["mvc"]["actions-uri"] = "{$wcROOTURI}/frontview/actions";
$wcPaths["mvc"]["layouts"] = "{$wcROOTDIR}/frontview/layouts";
$wcPaths["mvc"]["layouts-uri"] = "{$wcROOTURI}/frontview/layouts";
$wcPaths["mvc"]["skins"] = "{$wcROOTDIR}/skins";
$wcPaths["mvc"]["skins-uri"] = "{$wcROOTURI}/skins";
$wcPaths["mvc"]["pools"] = array(
	"actions" => array(
		$wcPaths["mvc"]["actions"]
	),
	"layouts" => array(
		$wcPaths["mvc"]["layouts"]
	),
	"skins" => array(
		"actions" => array(
		),
		"layouts" => array(
		)
	)
);
/* @} */

$wcSite["name"] = "My Comics Site";
$wcSite["email"] = "noreplay@localhost";
$wcSite["wiki"] = false;

/**
 * Extra menu items @{
 */
$wcMenuItems = array();
$wcMenuItems[WC_MENU_CODE_ADMIN] = array("top" => array(), "middle" => array(), "bottom" => array());
$wcMenuItems[WC_MENU_CODE_MAIN] = array("top" => array(), "middle" => array(), "bottom" => array());
$wcMenuItems[WC_MENU_CODE_SHORTCUTS] = array("top" => array(), "bottom" => array());
$wcMenuItems[WC_MENU_CODE_USER] = array("top" => array(), "middle" => array(), "bottom" => array());
$wcMenuBuilders = array();
/* @} */

/*
 * @{
 */
$wcCompressors = array();
$wcCompressors["RAR"] = array(
	"extensions" => array("cbr", "rar"),
	"binary" => "rar",
	"cmd-skeleton" => "{COMMAND} 'x' \"{COMIC}\" '-w' \"{DIRECTORY}\""
);
$wcCompressors["ZIP"] = array(
	"extensions" => array("cbz", "zip"),
	"binary" => "unzip",
	"cmd-skeleton" => "{COMMAND} \"{COMIC}\" '-d' \"{DIRECTORY}\""
);
$wcCompressors["TAR"] = array(
	"extensions" => array("cbt", "tar"),
	"binary" => "tar",
	"cmd-skeleton" => "{COMMAND} '-xf' \"{COMIC}\" '-C' \"{DIRECTORY}\""
);
/* @} */

$wcDefaults["debug"] = false;
$wcDefaults["errors"] = array(
	"errors" => true,
	"warnings" => false,
	"dies" => true,
	"logs" => true
);
$wcDefaults["avatar-basic"] = "{$wcROOTURI}/images/avatars";
$wcDefaults["avatar-theme"] = $wcDefaults["avatar-basic"];/** @deprecated */
$wcDefaults["avatar-skin"] = $wcDefaults["avatar-basic"];
$wcDefaults["avatar-cache"] = "{$wcPaths["cache-directory-uri"]}/avatars";
$wcDefaults["preview"] = "{$wcROOTURI}/images/wcomix-no-preview.png";
$wcDefaults["loading"] = "{$wcROOTURI}/images/wcomix-loading.gif";
$wcDefaults["icon-add"] = "{$wcROOTURI}/images/icons/add.png";
$wcDefaults["icon-delete"] = "{$wcROOTURI}/images/icons/delete.png";
$wcDefaults["icon-home"] = "{$wcROOTURI}/images/icons/wcomix-home.png";
$wcDefaults["icon-tag"] = "{$wcROOTURI}/images/icons/wcomix-folder-star.png";
$wcDefaults["icon-collection"] = "{$wcROOTURI}/images/icons/wcomix-folder-star.png";
$wcDefaults["icon-directory"] = "{$wcROOTURI}/images/icons/wcomix-folder.png";
$wcDefaults["icon-mobile"] = "{$wcROOTURI}/images/icons/wcomix-mobile.png";
$wcDefaults["icon-edit"] = "{$wcROOTURI}/images/icons/pencil.png";
$wcDefaults["icon-light-on"] = "{$wcROOTURI}/images/icons/light-on.png";
$wcDefaults["icon-light-off"] = "{$wcROOTURI}/images/icons/light-off.png";
$wcDefaults["icon-info"] = "{$wcROOTURI}/images/icons/wcomix-notice.png";
$wcDefaults["allow-hiddens"] = false;
$wcDefaults["thumbs-size"] = 128;  // in pixels.
$wcDefaults["group"] = false;
$wcDefaults["public-group"] = true;
$wcDefaults["installed"] = false;
$wcDefaults["session-max-time"] = 86400; // in seconds.
$wcDefaults["stats-max-time"] = 7;  // in days. 0 disables.
$wcDefaults["directory-permissions"] = 0777;
$wcDefaults["max-autoexpand"] = 50;
$wcDefaults["theme"] = "default";/** @deprecated */
$wcDefaults["theme-mobile"] = "mdefault";/** @deprecated */
$wcDefaults["skin"] = "Skoll";
$wcDefaults["skin-mobile"] = "Hati";
$wcDefaults["no-credits"] = false;
$wcDefaults["no-logs"] = true;
$wcDefaults["read-only"] = false;
$wcDefaults["image-board"] = true;
$wcDefaults["language"] = "en_us";
$wcDefaults["image-fix-extentions"] = false;

/*
 * Loading database structure specs
 * @{
 */
$wcDatabase["tables"][] = "/config/db/wc_parameters.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_cache.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_comments.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_collections.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_comics.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_comic_images.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_images.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_directories.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_groups.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_group_users.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_rr_comics.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_rr_images.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_rule_actions.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_rules.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_session_keeps.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_sessions.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_stats_timer.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_tag_comics.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_tag_images.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_tags.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_user_data.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_users.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_search_index.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_search_cache.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_search_words.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_lang_translations.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_mvc_actions.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_mvc_cache.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_mvc_urlcache.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_mvc_invalids.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_acts_tare.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_acts_dor.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_services_cache.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_previews.tab.xml";
$wcDatabase["tables"][] = "/config/db/wc_flows.tab.xml";

$wcDatabase["indexes"][] = "/config/db/wc_parameters.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_cache.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_comments-cmm_items.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_group_users.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_rr_comics.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_rr_images.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_sessions.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_stats_timer.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_tag_comics.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_tag_images.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_user_data.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_comics-cmc_name.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_comic_images-cim_position.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_comic_images-cim_md5.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_comic_images-cim_sha1.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_images-img_name.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_images-img_md5.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_images-img_sha1.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_directories-dir_name.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_stats_timer-st_t_sdate.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_tag_comics-mem_item.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_tag_images-mem_item.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_tags-tag_group.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_tags-tag_name.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_user_data-usd_email.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_users-usr_username.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_search_index.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_search_index-swi_word.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_search_cache.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_mvc_cache.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_mvc_urlcache.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_mvc_invalids.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_acts_tare.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_acts_dor.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_services_cache.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_previews.pk.xml";
$wcDatabase["indexes"][] = "/config/db/wc_previews-pvw_path.idx.xml";
$wcDatabase["indexes"][] = "/config/db/wc_flows.pk.xml";
/* @} */

$wcCronProfiles[$wcCronProfile] = array(
	"comic.updatenames",
	"image.updatenames",
	"directory.updatenames",
	"lists.update",
	"rules.run",
	"activetags.run",
	"lists.losts",
	"previews.update",
	"flows.update",
	"search.updateindex",
	"statistics.update",
	"translate.update",
	"mvc.cleancache"
);
$wcCronProfiles["tagger"] = array(
	"rules.run",
	"activetags.run",
	"previews.update",
	"flows.update",
	"search.updateindex"
);
$wcCronProfiles["names"] = array(
	"comic.updatenames",
	"image.updatenames",
	"directory.updatenames",
	"lists.update",
	"lists.losts",
	"previews.update",
	"search.updateindex"
);

$wcSpecialTags[] = WC_SPECIAL_TAG_DUPLICATED;
$wcSpecialTags[] = WC_SPECIAL_TAG_REORDER;
$wcSpecialTags[] = WC_SPECIAL_TAG_WRONG_TAGS;

$wcActiveTagHooks[WC_ACTIVE_TAG_TRASH] = array(
	"description" => "Items scheduled to be removed",
	"class" => "WCActiveTagGarbage"
);
$wcActiveTagHooks[WC_ACTIVE_TAG_UNTAGGED] = array(
	"description" => "Untagged entries update",
	"class" => "WCActiveTagUntagged"
);
$wcActiveTagHooks[WC_ACTIVE_TAG_FEW_TAGS] = array(
	"description" => "Untagged entries update",
	"class" => "WCActiveTagFewTags"
);
$wcActiveTagHooks[WC_ACTIVE_TAG_BLAST] = array(
	"description" => "Wipe out all tags and moves to group's root",
	"class" => "WCActiveTagBlastTags"
);
/** @} */
require_once "{$wcROOTDIR}/config/permissions.php";

//
// Services defaults: @{
$wcServicesDefaults = array();
$wcServicesDefaults["cache"] = array();
$wcServicesDefaults["cache"]["active"] = false;
$wcServicesDefaults["cache"]["expiration"] = 3600; // 1 hour.
$wcServicesDefaults["paths"] = array();
$wcServicesDefaults["paths"][] = $wcPaths["services"];
// @}
//
// Search Holders.
// @{
$wcSearchHolders = array();
// @}
//
// Languages.
// @{
$wcLanguageFolders = array(
	"{$wcROOTDIR}/lang"
);
// @}
//
// Action handlers for rss.
// @{
$wcRSSHandlers[WC_RSS_TAG] = "{$wcPaths["rss-directory"]}/r.tag.php";
// @}
// @formatter:on
require_once "{$wcPaths["config-directory"]}/includes.php";
//
// Loading tools.
// Warning: they only load when it is a shell execution.
// @{
if(defined("__SHELL__")) {
	require_once "{$wcPaths["tools-directory"]}/t.comic.clean.php";
	require_once "{$wcPaths["tools-directory"]}/t.directory.lostthumbs.php";
	require_once "{$wcPaths["tools-directory"]}/t.group.create.php";
	require_once "{$wcPaths["tools-directory"]}/t.items.betterone.php";
	require_once "{$wcPaths["tools-directory"]}/t.items.tag2group.php";
	require_once "{$wcPaths["tools-directory"]}/t.stats.search.php";
	require_once "{$wcPaths["tools-directory"]}/t.search.php";
}
// @}
// Personal configuration.
// @{
if(is_readable(WCSanitizer::SystemPath($wcPaths["config-local"]))) {
	require_once $wcPaths["config-local"];
} else {
	//
	// When there's no personal configuration the flag WC_NOT_INSTALLED is
	// set to indicate the system is not installed.
	define('WC_NOT_INSTALLED', true);

	@include $wcPaths["install-tmps"]["group"];
	@include $wcPaths["install-tmps"]["db"];
	@include $wcPaths["install-tmps"]["defaults"];

	if(is_readable($wcPaths["install-tmps"]["db"])) {
		WCMassiveInstaller::Instance()->install();
	}
}
// @}

if(!defined("WC_NOT_INSTALLED")) {
	if(isset($_REQUEST["forceskin"])) {
		if(is_dir("{$wcPaths["mvc"]["skins"]}/{$_REQUEST["forceskin"]}")) {
			$wcDefaults["skin"] = $_REQUEST["forceskin"];
			$wcDefaults["skin-mobile"] = $_REQUEST["forceskin"];
		}
	}

	require_once "{$wcROOTDIR}/config/post.config.php";

	$skinPath = "";
	if(defined("__MOBILE__")) {
		$skinPath = "{$wcPaths["mvc"]["skins"]}/{$wcDefaults["skin-mobile"]}";
	} else {
		$skinPath = "{$wcPaths["mvc"]["skins"]}/{$wcDefaults["skin"]}";
	}

	array_unshift($wcPaths["mvc"]["pools"]["skins"]["actions"], "{$skinPath}/actions");
	array_unshift($wcPaths["mvc"]["pools"]["skins"]["layouts"], "{$skinPath}/layouts");

	if(is_readable("{$skinPath}/config.json")) {
		$wcSkinConfig = json_decode(file_get_contents("{$skinPath}/config.json"));
	}
	completeSkinConfig();
	WCViewManager::I()->SKIN_CONFIG = $wcSkinConfig;
	if(is_readable("{$skinPath}/config.php")) {
		require "{$skinPath}/config.php";
	}
	//
	// Loading basic rule actions handlers.
	// @{
	require_once "{$wcROOTDIR}/config/rules.php";
	// @}
	WCMassiveInstaller::Instance()->install();
}
